#!/usr/bin/python
# -*- coding:UTF-8 -*-
# @Time    : 2018/11/20 15:22
# @Author  : Aries
# @Site    : 
# @File    : d3.py
# @Software: PyCharm
import time


def runTime(level=True):
    def wrapper(func):
        def inner_wrapper(*args, **kwargs):
            startTime = time.clock()  # 开始时间
            u = func(*args, **kwargs)
            endTime = time.clock()
            timeDifference = str(endTime - startTime)  # 时间差
            if level:
                print "%s方法执行完毕:用时%s秒" % (func.__name__, timeDifference[0:5])
            return u

        return inner_wrapper

    return wrapper


class Test(object):
    def __init__(self):
        pass

    def revive(self):
        print('revive from exception.')

    @runTime(level=True)
    def read_value(self, a, b, c):
        print('here I will do something.')

    def main(self):
        self.read_value("aa", "bb", "cc")


if __name__ == '__main__':
    aa = Test()
    aa.main()
    pass
